package com.halfsword.creativecraft.integration.jei;

import com.halfsword.creativecraft.CreativeCraft;
import com.halfsword.creativecraft.gui.machine.SpaceCollectorScreened;
import com.halfsword.creativecraft.recipe.SpaceCollectorRecipe;
import mezz.jei.api.IModPlugin;
import mezz.jei.api.JeiPlugin;
import mezz.jei.api.registration.IGuiHandlerRegistration;
import mezz.jei.api.registration.IRecipeCategoryRegistration;
import mezz.jei.api.registration.IRecipeRegistration;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.crafting.RecipeManager;
import org.jetbrains.annotations.NotNull;

import java.util.List;

@JeiPlugin
public class forJeiPlugin implements IModPlugin {
    @Override
    public @NotNull ResourceLocation getPluginUid() {
        return ResourceLocation.fromNamespaceAndPath(CreativeCraft.MOD_ID,"jei_plugin");
    }

    @Override
    public void registerCategories(IRecipeCategoryRegistration registration) {
        registration.addRecipeCategories(new SpaceCollectorCategory(registration.getJeiHelpers().getGuiHelper()));
    }


    @Override
    public void registerRecipes(IRecipeRegistration registration) {
        RecipeManager recipeManager = Minecraft.getInstance().level.getRecipeManager();
        List<SpaceCollectorRecipe> spaceCollectorRecipes =recipeManager.getAllRecipesFor(SpaceCollectorRecipe.Type.INSTANCE);
        registration.addRecipes(SpaceCollectorCategory.SPACE_COLLECTOR_TYPE,spaceCollectorRecipes);

    }

    @Override
    public void registerGuiHandlers(IGuiHandlerRegistration registration) {
        registration.addRecipeClickArea(SpaceCollectorScreened.class,163,11,20,20,SpaceCollectorCategory.SPACE_COLLECTOR_TYPE);
    }
}
